*************************************************************************************************
*                                                                                               *  
* The Importance of UN Peacekeeping Mission Orientation and Personnel for Environmental Quality *
*                                                                                               *
* Tobias Böhmelt                                                                                *   
*                                                                                               *
* This Version: January 19, 2024                                                                *
*                                                                                               *
*************************************************************************************************

**************
* Data Setup *
**************

use "C:\Users\tbohmelt\Google Drive\Peacekeeping Composition and Environment\Final Replication Materials\Final Data.dta", clear

sort gwnoloc year
xtset gwnoloc year

replace green=0 if green==. & iactual_civilian_total_K_2l!=.

replace iwdi_pop_3l=ln(1+iwdi_pop_3l)

replace iwdi_gdppc_3l=ln(1+iwdi_gdppc_3l)

replace iwdi_fuel_3l=ln(1+iwdi_fuel_3l)

gl ictrls_3l_varying iwdi_pop_3l c.iwdi_gdppc_3l##c.iwdi_gdppc_3l iwdi_fuel_3l polity2_3l

replace PKOdL= itotal_compound_K_2l +iactual_civilian_total_K_2l

replace PKOdL=1 if PKOdL>0 & PKOdL!=.

************
* Figure 1 *
************

preserve
generate where1 = 1
gen conflict_placer=year if ucdp_0yrs==1
generate where2 = -1
generate PKO_placer=year if PKOdL==1
generate pipe = "|"
xtline progress, recast(scatter) msymbol(smcircle) i(country) t(year) addplot((scatter where1 conflict_placer, ms(none) blcolor(gray) mlabel(pipe) mlabpos(0)) (scatter where2 PKO_placer, ms(none) blcolor(gray) mlabel(pipe) mlabpos(0))) scheme(538w) aspectratio(1)
restore

***********
* Table 2 *
***********

eststo clear
eststo: xtreg progress l.progress PKOdL i.year, fe
estimates store reg1
eststo: xtreg progress l.progress PKOdL $ictrls_3l_varying i.year, fe
estimates store reg2
eststo: xtreg progress l.progress PKOdL $ictrls_3l_varying i.year if ucdp_0yrs==1, fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "Table1.tex",   /*
 */ se title(Peacekeeping and Environmental Quality)  nonumbers /*
 */ mtitles("Model 1" "Model 2" "Model 3") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace 

***********
* Table 3 *
***********

eststo clear 
eststo: xtreg progress l.progress l2.green i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg1
eststo: xtreg progress l.progress l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg2
eststo: xtreg progress l.progress l2.green $ictrls_3l_varying i.year if ucdp_0yrs==1 & iactual_civilian_total_K_2l!=., fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "Table2.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Green Mandate)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace 

***********
* Table 4 *
***********

eststo clear  
eststo: xtreg progress l.progress itotal_compound_K_2l i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg1
eststo: xtreg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg2
eststo: xtreg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year if ucdp_0yrs==1 & iactual_civilian_total_K_2l!=., fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "Table3.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Uniformed Personnel)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace 

***********
* Table 5 *
***********

eststo clear  
eststo: xtreg progress l.progress iactual_civilian_total_K_2l i.year, fe
estimates store reg1
eststo: xtreg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year, fe
estimates store reg2
eststo: xtreg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year if ucdp_0yrs==1, fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "Table4.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Civilian Personnel)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace 

************
* Figure 2 *
************ 

qui reg progress l.progress l2.green $ictrls_3l_varying i.year i.gwnoloc if iactual_civilian_total_K_2l!=.
margins, at(l2.green=(0 1)) atmeans level(90)
marginsplot, level(90) name(graph2, replace) legend(off) scheme(538w) aspectratio(1)
qui reg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year i.gwnoloc if iactual_civilian_total_K_2l!=.
margins, at(itotal_compound_K_2l=(0(3)33)) atmeans level(90)
marginsplot, recast(line) ciopts(recast(rline) lpattern(dash)) level(90) name(graph3, replace) legend(off) scheme(538w) aspectratio(1)
qui reg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year i.gwnoloc
margins, at(iactual_civilian_total_K_2l=(0(1)9)) atmeans level(90)
marginsplot, recast(line) ciopts(recast(rline) lpattern(dash)) level(90) name(graph4, replace) legend(off) scheme(538w) aspectratio(1)
graph combine graph2 graph3 graph4, ycommon row(1)
 
***********
* Table 6 *
***********

eststo clear   
preserve
drop if PKOdL==.
cem iwdi_pop_3l iwdi_gdppc_3l iwdi_fuel_3l polity2_3l if iactual_civilian_total_K_2l!=., treatment(PKOdL)
eststo: reg progress l.progress l2.green $ictrls_3l_varying i.year i.gwnoloc [iweight=cem_w] 
estimates store reg1
eststo: reg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year i.gwnoloc [iweight=cem_w]
estimates store reg2
eststo: reg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year i.gwnoloc [iweight=cem_w]
estimates store reg3
esttab reg1 reg2 reg3, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "Table5.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Matched Sample)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace 
restore

*********************
* Robustness Checks *
*********************

pwcorr l2.green itotal_compound_K_2l iactual_civilian_total_K_2l, sig
eststo clear 
eststo: xtreg progress l.progress l2.green itotal_compound_K_2l iactual_civilian_total_K_2l i.year, fe
estimates store reg1
eststo: xtreg progress l.progress l2.green itotal_compound_K_2l iactual_civilian_total_K_2l $ictrls_3l_varying i.year, fe
estimates store reg2
eststo: xtreg progress l.progress l2.green itotal_compound_K_2l iactual_civilian_total_K_2l $ictrls_3l_varying i.year if ucdp_0yrs==1, fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA1.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- All Main Explanatory Variables)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace 

eststo clear 
eststo: xtpcse progress l.progress l2.green $ictrls_3l_varying i.year i.gwnoloc if iactual_civilian_total_K_2l!=., c(psar1) het
estimates store reg1
eststo: xtpcse progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year i.gwnoloc if iactual_civilian_total_K_2l!=., c(psar1) het
estimates store reg2
eststo: xtpcse progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year i.gwnoloc if iactual_civilian_total_K_2l!=., c(psar1) het
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA2.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Panel-Corrected Standard Errors)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace  
 
eststo clear 
eststo: xtreg progress l.progress l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe robust
estimates store reg1
eststo: xtreg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe robust
estimates store reg2
eststo: xtreg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe robust
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA3.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Clustered Standard Errors)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace 
 
eststo clear 
eststo: xtreg progress l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg1
eststo: xtreg progress itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg2
eststo: xtreg progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA4.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Without Lagged Dependent Variable)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace

eststo clear 
eststo: xtreg progress l.progress l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., re
estimates store reg1
eststo: xtreg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., re
estimates store reg2
eststo: xtreg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., re
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA5.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Random Effects Estimation)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace  
 
eststo clear 
eststo: reg progress l.progress l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=.
estimates store reg1
eststo: reg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=.
estimates store reg2
eststo: reg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=.
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA6.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Without Fixed/Random Effects)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace  

eststo clear 
xtreg progress l.progress l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
xtreg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year if e(sample), fe
xtreg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year if e(sample), fe
eststo: xtreg progress l.progress l2.green $ictrls_3l_varying i.year if e(sample), fe
estimates store reg1
eststo: xtreg progress l.progress itotal_compound_K_2l $ictrls_3l_varying i.year if e(sample), fe
estimates store reg2
eststo: xtreg progress l.progress iactual_civilian_total_K_2l $ictrls_3l_varying i.year if e(sample), fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA7.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Same Sample Across Estimations)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace  

ipolate wdi_enerenew year, gen(i_wdi_enerenew) epolate by(gwnoloc)
eststo clear 
eststo: xtreg i_wdi_enerenew l.i_wdi_enerenew l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg1
eststo: xtreg i_wdi_enerenew l.i_wdi_enerenew itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg2
eststo: xtreg i_wdi_enerenew l.i_wdi_enerenew iactual_civilian_total_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA8.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Alternative Dependent Variable: Renewable Energy Consumption)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace  
 
ipolate wdi_elerenew year, gen(i_wdi_elerenew) epolate by(gwnoloc)
eststo clear 
eststo: xtreg i_wdi_elerenew l.i_wdi_elerenew l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg1
eststo: xtreg i_wdi_elerenew l.i_wdi_elerenew itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg2
eststo: xtreg i_wdi_elerenew l.i_wdi_elerenew iactual_civilian_total_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA9.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Alternative Dependent Variable: Renewable Energy Output)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace  

gen progress_new=1 if progress>0 & progress!=. 
replace progress_new=0 if progress_new==. & progress!=.
eststo clear 
eststo: xtreg progress_new l.progress_new l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg1
eststo: xtreg progress_new l.progress_new itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg2
eststo: xtreg progress_new l.progress_new iactual_civilian_total_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA10.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Alternative Dependent Variable: Dichotomous Water Quality Progress)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace  

ipolate wdi_co2 year, gen(i_wdi_co2) epolate by(gwnoloc)
eststo clear 
eststo: xtreg i_wdi_co2 l.i_wdi_co2 l2.green $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg1
eststo: xtreg i_wdi_co2 l.i_wdi_co2 itotal_compound_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg2
eststo: xtreg i_wdi_co2 l.i_wdi_co2 iactual_civilian_total_K_2l $ictrls_3l_varying i.year if iactual_civilian_total_K_2l!=., fe
estimates store reg3
esttab reg1 reg2 reg3, aic se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA11.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Alternative Dependent Variable: CO2 Emissions)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace  
 
eststo clear   
gen greenl2=l2.green
bysort year: egen test = total(greenl2)
bysort year: egen inc_sum = max(test)
drop test
bysort year: egen test = count(greenl2)
bysort year: egen count_inc = max(test)
drop test
bysort gwnoloc year: egen inc_sum_country = total(greenl2)
bysort gwnoloc year: egen count_inc_country = count(greenl2)
gen test = (inc_sum-inc_sum_country)/(count_inc-count_inc_country)
bysort gwnoloc year: egen green_l2_spatial = max(test)
replace green_l2_spatial = inc_sum/count_inc if green_l2_spatial==.
capture drop greenl2 inc_sum count_inc inc_sum_country count_inc_country test
eststo: ivregress 2sls progress l.progress $ictrls_3l_varying i.year i.gwnoloc (l2.green = green_l2_spatial) if iactual_civilian_total_K_2l!=., small
estimates store reg1

bysort year: egen test = total(itotal_compound_K_2l)
bysort year: egen inc_sum = max(test)
drop test
bysort year: egen test = count(itotal_compound_K_2l)
bysort year: egen count_inc = max(test)
drop test
bysort gwnoloc year: egen inc_sum_country = total(itotal_compound_K_2l)
bysort gwnoloc year: egen count_inc_country = count(itotal_compound_K_2l)
gen test = (inc_sum-inc_sum_country)/(count_inc-count_inc_country)
bysort gwnoloc year: egen itotal_compound_K_2l_spatial = max(test)
replace itotal_compound_K_2l_spatial = inc_sum/count_inc if itotal_compound_K_2l_spatial==.
capture drop inc_sum count_inc inc_sum_country count_inc_country test
eststo: ivregress 2sls progress l.progress $ictrls_3l_varying i.year i.gwnoloc (itotal_compound_K_2l = itotal_compound_K_2l_spatial) if iactual_civilian_total_K_2l!=., small
estimates store reg2

bysort year: egen test = total(iactual_civilian_total_K_2l)
bysort year: egen inc_sum = max(test)
drop test
bysort year: egen test = count(iactual_civilian_total_K_2l)
bysort year: egen count_inc = max(test)
drop test
bysort gwnoloc year: egen inc_sum_country = total(iactual_civilian_total_K_2l)
bysort gwnoloc year: egen count_inc_country = count(iactual_civilian_total_K_2l)
gen test = (inc_sum-inc_sum_country)/(count_inc-count_inc_country)
bysort gwnoloc year: egen iactual_civilian_total_K_2l_sp = max(test)
replace iactual_civilian_total_K_2l_sp = inc_sum/count_inc if iactual_civilian_total_K_2l_sp==.
capture drop inc_sum count_inc inc_sum_country count_inc_country test
eststo: ivregress 2sls progress l.progress $ictrls_3l_varying i.year i.gwnoloc (iactual_civilian_total_K_2l = iactual_civilian_total_K_2l_sp), small
estimates store reg3

esttab reg1 reg2 reg3, se star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) label
esttab using "TableA12.tex",   /*
 */ se title(Peacekeeping and Environmental Quality -- Instrumental Variables)  nonumbers /*
 */ mtitles("(1)" "(2)" "(3)") label nodep nogaps star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) /*
 */ nonotes addnotes("$*$ p < 0.10, $**$ p < 0.05, $***$ p < 0.01" "Standard errors in parentheses") replace 